package behavior.strategy;

public class Demo {
    public static void main(String[] args) {
        // 通过上下文调用策略模式
        ActionStrategyContext context = new ActionStrategyContext();
        context.setActionStrategy(new DefenseStrategy());
        context.action();
        context.setActionStrategy(new RetreatStrategy());
        context.action();

        // 通过工厂调用策略模式

        ActionStrategyFactory.getActionStrategy("attack").action();
        ActionStrategyFactory.getActionStrategy("retreat").action();
        ActionStrategyFactory.getActionStrategy("defense").action();
    }
}
